<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/dest/css/reset.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/dest/css/global.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/dest/css/zdialog.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/dest/css/wodelicai.css">
    <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_640143_4xmg09t955t57b9.css">
    <title>交易记录</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

</head>
<!-- 个人中心的容器 start -->
<body id="self">
<div id="nav-title">
    <span class="iconfont icon-Left back" onclick="jump('/index.php/home/Trade/jymr/')"></span>
    木材交易记录
</div>

<div class="self_wrap">

    <!-- 个人信息 start -->
    <div class="self-info">
        <div class="part-one">
            <div class="name_phone">
                <!-- <p>等级:健康大使</p> -->
            </div>
        </div>
        <div class="part-two clear">
            <p class="number">{$life_tree}</p>

            <p class="title">生命树</p>
        </div>
        <div class="part-three" layout="rows center-justify">
            <div self="size-x1" class="item">
                <p class="title">买入总数</p>
                <p class="number">{$mr_sum}</p>
            </div>
            <div self="size-x1" class="item">
                <p class="title"> 卖出总数</p>
                <p class="number">{$mc_sum}</p>
            </div>
        </div>
    </div>
    <!-- 个人信息 end -->

    <div class="tables">
        <h4>交易明细</h4>
        <div class="tables-scroll">
            <table class="table" id="table">
                <thead>
                <tr>
                    <th style="width: 30%">时间</th>
                    <th style="width: 20%">交易数量</th>
                    <th style="width: 20%">价格</th>
                    <th style="width: 10%">状态</th>
                    <th style="width: 10%">交易类型</th>
                    <th style="width: 10%">操作</th>
                </tr>
                </thead>
                <tbody>

                <foreach name='list' item='v'>
                    <tr>
                        <td>{$v.create_time}</td>
                        <td>{$v.tree}</td>
                        <td>{$v.price}</td>
                        <td>
                            <if condition="$v.status eq -1">已撤销</if>
                            <if condition="$v.status eq 0">交易中</if>
                            <if condition="$v.status eq 1">已完成</if>
                        </td>
                        <td>
                            <if condition="$v.type eq 1">买入</if>
                            <if condition="$v.type eq 2">卖出</if>
                        </td>
                        <td>
                            <if condition="$v.status eq 0">
                                <button class="btn btn-default" alt="{$v.id}" onclick="chedan(this)" style="padding: 3px 12px;">撤单</button>
                            </if>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </div>
    </div>
</div>

</body>
<!-- 个人中心的容器 end -->

<script src="__PUBLIC__/dest/js/lib/zepto.min.js"></script>
<!-- <script src="../js/lib/wui.min.js"></script> -->
<script src="__PUBLIC__/dest/js/lib/global.js"></script>
<script src="__PUBLIC__/dest/js/lib/zdialog.js"></script>
<script>
    function chedan(e){
        var id=$(e).attr("alt");
        $(e).attr("disabled","true");
        if(confirm("确认撤单？")){
            $.ajax({
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/index.php/Home/Trade/chedan/" ,//url
                data: {
                    "id":id
                },
                success: function (result) {
                    if (result.status == 1) {
                        alert("操作成功");
                        $(e).hide();
                        var date_obj = new Date();
                        window.location.href = window.location.href + '?timestamp=' + date_obj.getTime();
                    }else{
                        alert(result.msg);
                    }
                },
                error : function() {
                    alert("操作失败,请刷新页面！");
                }
            });

        }
    }

</script>
</html>